$scheduler-toolbar-color: var(--rz-text-contrast-color) !default;
$scheduler-toolbar-button-background-color: var(--rz-secondary) !default;

// -----

$scheduler-border: var(--rz-border-normal) !default;
$scheduler-border-color: var(--rz-base-300) !default;
$scheduler-minor-border-color: var(--rz-base-200) !default;
$scheduler-border-radius: var(--rz-border-radius) !default;
$scheduler-shadow: 0 8px 10px 0 rgba(0, 0, 0, 0.01) !default;
$scheduler-background-color: var(--rz-base-background-color) !default;
$scheduler-color: var(--rz-text-tertiary-color) !default;

$scheduler-toolbar-padding: 0.5rem !default;
$scheduler-toolbar-background-color: var(--rz-base-200) !default;

$scheduler-toolbar-title-font-size: 1rem !default;
$scheduler-toolbar-title-font-weight: 700 !default;
$scheduler-toolbar-title-color: var(--rz-text-title-color) !default;

$scheduler-prev-next-button-background-color: $scheduler-toolbar-button-background-color !default;
$scheduler-prev-next-button-color: $scheduler-toolbar-color !default;
$scheduler-prev-next-button-padding: 0.5rem !default;
$scheduler-prev-next-button-font-size: var(--rz-icon-size) !default;
$scheduler-prev-button-border-radius: var(--rz-border-radius) 0 0 var(--rz-border-radius) !default;
$scheduler-next-button-border-radius: 0 var(--rz-border-radius) var(--rz-border-radius) 0 !default;

$scheduler-today-button-margin-left: 0.5rem !default;
$scheduler-today-button-padding: 0.5rem 1rem !default;
$scheduler-today-button-font-size: 0.75rem !default;
$scheduler-today-button-text-transform: uppercase !default;

$scheduler-view-button-border: var(--rz-border-normal) !default;
$scheduler-view-button-color: var(--rz-text-secondary-color) !default;
$scheduler-view-button-background-color: var(--rz-base-background-color) !default;
$scheduler-view-selected-color: var(--rz-text-contrast-color) !default;
$scheduler-view-selected-background-color: var(--rz-secondary) !default;
$scheduler-view-selected-border-color: $scheduler-view-selected-background-color !default;

$scheduler-header-background-color: var(--rz-base-200) !default;
$scheduler-header-font-size: 0.75rem !default;
$scheduler-header-font-size-small: 0.5rem !default;
$scheduler-header-text-transform: uppercase !default;
$scheduler-header-color: inherit !default;
$scheduler-header-border: var(--rz-border-normal) !default;
$scheduler-header-padding: 0.5rem 0 !default;

$scheduler-event-color: var(--rz-text-contrast-color) !default;
$scheduler-event-background-color: var(--rz-info) !default;
$scheduler-event-font-size: 0.75rem !default;
$scheduler-event-line-height: 1.25rem !default;
$scheduler-event-padding: 0 1px 1px 1px !default;
$scheduler-event-content-padding: 0.125rem 0.25rem !default;

$scheduler-event-list-button-color: var(--rz-secondary);
$scheduler-event-list-button-font-size: 0.75rem;

$scheduler-slot-title-font-size: 0.875rem !default;
$scheduler-slot-title-font-size-small: 0.6rem !default;
$scheduler-slot-title-padding: 0 0.25rem !default;

$scheduler-day-number-padding: 0 0.5rem !default;

$scheduler-weekend-color: var(--rz-text-disabled-color) !default;
$scheduler-weekend-background-color: var(--rz-base-50) !default;
$scheduler-other-month-background-color: var(--rz-base-100) !default;

$scheduler-timeline-slot-width: 7rem !default;
$scheduler-timeline-slot-height: 7rem !default;

$scheduler-year-padding: 1.5rem !default;
$scheduler-year-slot-padding: 1px !default;
$scheduler-year-slot-title-width: 100% !default;
$scheduler-year-slot-title-border-radius: 0.25rem !default;

$scheduler-planner-slot-width: 3rem !default;
$scheduler-planner-slot-height: 4.5rem !default;

// Scheduler CSS variables

:root {
  --rz-scheduler-border: #{$scheduler-border};
  --rz-scheduler-border-color: #{$scheduler-border-color};
  --rz-scheduler-minor-border-color: #{$scheduler-minor-border-color};
  --rz-scheduler-border-radius: #{$scheduler-border-radius};
  --rz-scheduler-shadow: #{$scheduler-shadow};
  --rz-scheduler-background-color: #{$scheduler-background-color};
  --rz-scheduler-color: #{$scheduler-color};
  
  --rz-scheduler-toolbar-padding: #{$scheduler-toolbar-padding};
  --rz-scheduler-toolbar-background-color: #{$scheduler-toolbar-background-color};
  
  --rz-scheduler-toolbar-title-font-size: #{$scheduler-toolbar-title-font-size};
  --rz-scheduler-toolbar-title-font-weight: #{$scheduler-toolbar-title-font-weight};
  --rz-scheduler-toolbar-title-color: #{$scheduler-toolbar-title-color};
  
  --rz-scheduler-prev-next-button-background-color: #{$scheduler-prev-next-button-background-color};
  --rz-scheduler-prev-next-button-color: #{$scheduler-prev-next-button-color};
  --rz-scheduler-prev-next-button-padding: #{$scheduler-prev-next-button-padding};
  --rz-scheduler-prev-next-button-font-size: #{$scheduler-prev-next-button-font-size};
  --rz-scheduler-prev-button-border-radius: #{$scheduler-prev-button-border-radius};
  --rz-scheduler-next-button-border-radius: #{$scheduler-next-button-border-radius};

  --rz-scheduler-today-button-margin-left: #{$scheduler-today-button-margin-left};
  --rz-scheduler-today-button-padding: #{$scheduler-today-button-padding};
  --rz-scheduler-today-button-font-size: #{$scheduler-today-button-font-size};
  --rz-scheduler-today-button-text-transform: #{$scheduler-today-button-text-transform};
  
  --rz-scheduler-view-button-border: #{$scheduler-view-button-border};
  --rz-scheduler-view-button-color: #{$scheduler-view-button-color};
  --rz-scheduler-view-button-background-color: #{$scheduler-view-button-background-color};
  --rz-scheduler-view-selected-color: #{$scheduler-view-selected-color};
  --rz-scheduler-view-selected-background-color: #{$scheduler-view-selected-background-color};
  --rz-scheduler-view-selected-border-color: #{$scheduler-view-selected-border-color};
  
  --rz-scheduler-header-background-color: #{$scheduler-header-background-color};
  --rz-scheduler-header-font-size: #{$scheduler-header-font-size};
  --rz-scheduler-header-font-size-small: #{$scheduler-header-font-size-small};
  --rz-scheduler-header-text-transform: #{$scheduler-header-text-transform};
  --rz-scheduler-header-color: #{$scheduler-header-color};
  --rz-scheduler-header-border: #{$scheduler-header-border};
  --rz-scheduler-header-padding: #{$scheduler-header-padding};
  
  --rz-scheduler-event-color: #{$scheduler-event-color};
  --rz-scheduler-event-background-color: #{$scheduler-event-background-color};
  --rz-scheduler-event-font-size: #{$scheduler-event-font-size};
  --rz-scheduler-event-line-height: #{$scheduler-event-line-height};
  --rz-scheduler-event-padding: #{$scheduler-event-padding};
  --rz-scheduler-event-content-padding: #{$scheduler-event-content-padding};

  --rz-scheduler-event-list-button-color: #{$scheduler-event-list-button-color};
  --rz-scheduler-event-list-button-font-size: #{$scheduler-event-list-button-font-size};
  
  --rz-scheduler-slot-title-font-size: #{$scheduler-slot-title-font-size};
  --rz-scheduler-slot-title-font-size-small: #{$scheduler-slot-title-font-size-small};
  --rz-scheduler-slot-title-padding: #{$scheduler-slot-title-padding};

  --rz-scheduler-day-number-padding: #{$scheduler-day-number-padding};

  --rz-scheduler-weekend-color: #{$scheduler-weekend-color};
  --rz-scheduler-weekend-background-color: #{$scheduler-weekend-background-color};
  --rz-scheduler-other-month-background-color: #{$scheduler-other-month-background-color};
  
  --rz-scheduler-timeline-slot-width: #{$scheduler-timeline-slot-width};
  --rz-scheduler-timeline-slot-height: #{$scheduler-timeline-slot-height};
  
  --rz-scheduler-year-padding: #{$scheduler-year-padding};
  --rz-scheduler-year-slot-padding: #{$scheduler-year-slot-padding};
  --rz-scheduler-year-slot-title-width: #{$scheduler-year-slot-title-width};
  --rz-scheduler-year-slot-title-border-radius: #{$scheduler-year-slot-title-border-radius};

  --rz-scheduler-planner-slot-width: #{$scheduler-planner-slot-width};
  --rz-scheduler-planner-slot-height: #{$scheduler-planner-slot-height};
}

.rz-scheduler {
  display: flex;
  height: 400px;
  flex-direction: column;
  border-radius: var(--rz-scheduler-border-radius);
  border: 1px solid var(--rz-scheduler-border-color);
  box-shadow: var(--rz-scheduler-shadow);
  color: var(--rz-scheduler-color);
  background: var(--rz-scheduler-background-color);
  overflow: hidden;
  background-clip: border-box;

  a.rz-event-list-btn {
    position: absolute;
    padding-left: 0.25rem;
    color: var(--rz-scheduler-event-list-button-color);
    font-size: var(--rz-scheduler-event-list-button-font-size);

    &:hover {
      cursor: pointer;
      color: var(--rz-scheduler-event-list-button-color);
      text-decoration: underline;
    }
  }
}

.rz-slot {
  display: flex;
  height: 1.5em;
  border-top: 1px solid var(--rz-scheduler-border-color);
  border-left: 1px solid var(--rz-scheduler-border-color);
}

.rz-slot-title {
  text-align: right;
  font-size: var(--rz-scheduler-slot-title-font-size);
  padding: var(--rz-scheduler-slot-title-padding);
}

.rz-slot-hours {
  .rz-slot-header {
    height: 1.5rem;
    text-align: right;
    font-size: var(--rz-scheduler-header-font-size);
    padding: 0 0.25rem;
    width: 5rem;
    border-right: 1px solid var(--rz-scheduler-border-color);
    white-space: nowrap;
  }
}

.rz-slot-minor {
  border-top: 1px solid var(--rz-scheduler-minor-border-color);
}

.rz-day-view,
.rz-slots:first-child {
  .rz-slot {
    border-left: none;
  }
}

.rz-event {
  position: absolute;
  padding: var(--rz-scheduler-event-padding);
  cursor: pointer;
}

.rz-event-content {
  background: var(--rz-scheduler-event-background-color);
  border-radius: var(--rz-scheduler-border-radius);
  color: var(--rz-scheduler-event-color);
  height: 100%;
  padding: var(--rz-scheduler-event-content-padding);
  font-size: var(--rz-scheduler-event-font-size);
  line-height: var(--rz-scheduler-event-line-height);
  overflow: hidden;
}

.rz-events {
  position: relative;
}

.rz-scheduler-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: var(--rz-scheduler-toolbar-padding);
  background: var(--rz-scheduler-toolbar-background-color);

  .rz-scheduler-nav-title {
    display: flex;
    align-self: center;
    font-size: var(--rz-scheduler-toolbar-title-font-size);
    font-weight: var(--rz-scheduler-toolbar-title-font-weight);
    color: var(--rz-scheduler-toolbar-title-color);
  }
}

.rz-view-header {
  border-top: var(--rz-scheduler-header-border);
  border-bottom: var(--rz-scheduler-header-border);
  background-color: var(--rz-scheduler-header-background-color);
  text-transform: var(--rz-scheduler-header-text-transform);
  color: var(--rz-scheduler-header-color);
  display: flex;

  .rz-slot-header {
    flex: 1;
    text-align: center;
    font-size: var(--rz-scheduler-header-font-size);
    padding: var(--rz-scheduler-header-padding);
  }

  .rz-slot-hour-header {
    flex: none;
    width: 80px;
  }
}

.rz-view {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.rz-view-content {
  flex: auto;
  display: flex;
  overflow: auto;
  height: 0;
}

.rz-slots {
  flex: 1;
  font-size: 1rem;
}

.rz-scheduler-nav-views {
  display: flex;

  .rz-button.rz-primary {
    background: var(--rz-scheduler-view-button-background-color);
    color: var(--rz-scheduler-view-button-color);
    border: var(--rz-scheduler-view-button-border);
    border-radius: 0;

    &:first-child {
      border-top-left-radius: var(--rz-scheduler-border-radius);
      border-bottom-left-radius: var(--rz-scheduler-border-radius);
      border-right: none;
    }

    &:last-child {
      border-top-right-radius: var(--rz-scheduler-border-radius);
      border-bottom-right-radius: var(--rz-scheduler-border-radius);
      border-left: none;
    }

    &.rz-state-active {
      background-color: var(--rz-scheduler-view-selected-background-color);
      border-color: var(--rz-scheduler-view-selected-border-color);
      color: var(--rz-scheduler-view-selected-color);
    }
  }
}

.rz-scheduler-nav-prev-next {
  display: flex;

  .rz-button {
    background-color: var(--rz-scheduler-prev-next-button-background-color);
    color: var(--rz-scheduler-prev-next-button-color);
    padding: var(--rz-scheduler-prev-next-button-padding);
    font-size: var(--rz-scheduler-prev-next-button-font-size);

    &.rz-today {
      margin-left: var(--rz-scheduler-today-button-margin-left);
      padding: var(--rz-scheduler-today-button-padding);
      font-size: var(--rz-scheduler-today-button-font-size);
      text-transform: var(--rz-scheduler-today-button-text-transform);
    }

    &.rz-prev {
      border-radius: var(--rz-scheduler-prev-button-border-radius);
    }

    &.rz-next {
      border-radius: var(--rz-scheduler-next-button-border-radius);
    }
  }
}

.rz-event-list {
  .rz-event {
    position: static;
  }
}

// Week range slots

.rz-week {
  flex: 1;
  font-size: 1rem;

  .rz-slots {
    display: flex;
    height: 100%;
  }

  &:first-child .rz-slot {
    border-top: none;
  }
}

// Month range slots
.rz-month {
  flex: 1;
  font-size: 1rem;

  .rz-slots {
    display: flex;
    height: 100%;
  }

  &:nth-child(2) .rz-slot {
    border-top: none;
  }

  .rz-slot {
    flex: 1;
    height: 100%;
    display: flex;
    border-top: 1px solid var(--rz-scheduler-border-color);
    border-left: 1px solid var(--rz-scheduler-border-color);
  
    &:first-child {
      position: sticky;
      z-index: 9998;
      left: 0;
      justify-content: center;
      align-items: center;
      background-color: var(--rz-scheduler-header-background-color);
      border-left: none;
      border-right: 1px solid var(--rz-scheduler-border-color);


      .rz-slot-header {
        text-align: center;
        font-size: var(--rz-scheduler-header-font-size);
        padding: var(--rz-scheduler-header-padding);
        text-transform: var(--rz-scheduler-header-text-transform);
        color: var(--rz-scheduler-header-color);
      }
    }

    &:nth-child(2) {
      border-left: none;
    }
  }
}

// Day View

.rz-day-view{
  .rz-slot:nth-of-type(2) {
    border-top: none;
  }

  .rz-view-header {
    padding-right: 15px;
  }
}

// Week View

.rz-week-view-content {
  flex: 1;
  display: flex;
}

.rz-week-view {
  .rz-slot:nth-of-type(2) {
    border-top: none;
  }

  .rz-view-header {
    padding-right: 15px;
  }
}

// Month View

.rz-month-view {
  .rz-view-content {
    flex: 1;
    flex-direction: column;
  }

  .rz-slot {
    flex: 1;
    height: 100%;

    &:first-child {
      border-left: none;
    }
  }
}

// Planner View

.rz-planner-view {
  overflow: auto;

  .rz-view-header {
    position: sticky;
    top: 0px;
    min-height: 2.25rem;
    z-index: 9999;
  }

  .rz-month {
    .rz-slot {
      &:first-child {
        .rz-slot-header {
          writing-mode: vertical-lr;
          transform: rotate(-180deg);
        }
      }

      &:last-child {
        justify-content: center;
        align-items: center;
        background-color: var(--rz-scheduler-header-background-color);
  
        .rz-slot-header {
          writing-mode: vertical-rl;
          text-align: center;
          font-size: var(--rz-scheduler-header-font-size);
          padding: var(--rz-scheduler-header-padding);
          text-transform: var(--rz-scheduler-header-text-transform);
          color: var(--rz-scheduler-header-color);
        }
      }

      &.rz-other-month {
        background-color: var(--rz-scheduler-other-month-background-color);
      }

      &.rz-weekend {
        color: var(--rz-scheduler-weekend-color);
        background-color: var(--rz-scheduler-weekend-background-color);
      }
    }
  }
}

// Timeline View

.rz-timeline-view {
  flex: auto;
  overflow: auto;
  flex-wrap: wrap;
  flex-direction: unset;

  .rz-view-header {
    position: sticky;
    top: 0px;
    min-height: 36px;
    z-index: 9999;

    .rz-slot-header {
      min-width: var(--rz-scheduler-timeline-slot-width);
      flex: 0 0 auto;
    }
  }

  .rz-month {
    flex: 0 0 auto;
  
    .rz-slots {
      flex: 0 0 auto;
    }
  
    .rz-slot {
      width: var(--rz-scheduler-timeline-slot-width);
      height: var(--rz-scheduler-timeline-slot-height);

      &.rz-other-month {
        background-color: var(--rz-scheduler-other-month-background-color);
      }

      &.rz-weekend {
        color: var(--rz-scheduler-weekend-color);
        background-color: var(--rz-scheduler-weekend-background-color);
      }
    }
  }
}

// Year View

.rz-year-view {
  overflow: auto;
  padding: var(--rz-scheduler-year-padding);
  --rz-gap: var(--rz-scheduler-year-padding);

  .rz-flex-column,
  .rz-week {
    min-width: fit-content;
  }

  .rz-slot {
    flex: 1;
    border-top: none;
    justify-content: center;
    height: initial;
    padding: var(--rz-scheduler-year-slot-padding);
    cursor: pointer;

    .rz-slot-title {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      text-align: center;
      width: var(--rz-scheduler-year-slot-title-width);
      min-width: 2rem;
      min-height: 2rem;
      border-radius: var(--rz-scheduler-year-slot-title-border-radius);
      transition: var(--rz-datepicker-calendar-transition);

      &.rz-other-month {
        opacity: 0.5;
      }

      &.rz-has-appointments {
        color: var(--rz-scheduler-event-color);
        background-color: var(--rz-scheduler-event-background-color)
      }
    }

    &:hover {
      .rz-slot-title:not(.rz-has-appointments) {
        color: var(--rz-datepicker-calendar-hover-color);
        background: var(--rz-datepicker-calendar-hover-background-color);
      }
    }
  }
}

// Responsive Styles

@media (max-width: 576px) {
  .rz-scheduler-nav {
    .rz-scheduler-nav-prev-next {
      justify-content: space-between;
      margin-bottom: 0.5rem;
      margin-right: 0.5rem;
      order: 1;
    }

    .rz-scheduler-nav-title {
      justify-content: center;
      width: 100%;
      order: 3;
    }

    .rz-scheduler-nav-views {
      margin-bottom: 0.5rem;
      justify-content: center;
      flex-grow: 1;
      order: 2;

      .rz-button {
        flex-grow: 1;
        padding-left: 0.5rem;
        padding-right: 0.5rem;

        .rz-button-text {
          display: none;
        }
      }
    }
  }

  .rz-slot-hours {
    .rz-slot-header {
      width: auto;
    }
  }
}

@media (max-width: 1399px) {
  .rz-planner-view {
    flex-wrap: wrap;
    flex-direction: unset;

    .rz-view-header {
      .rz-slot-header {
        flex: 0 0 auto;
        width: var(--rz-scheduler-planner-slot-width);
      }
    }

    .rz-month {
      flex: 0 0 auto;

      .rz-slots {
        flex: 0 0 auto;
      }

      .rz-slot {
        width: var(--rz-scheduler-planner-slot-width);
        height: var(--rz-scheduler-planner-slot-height);
      }
    }
  }
}
